<html>
<head>
	<script>
var ajaxku;
function ambildata(kls){
 ajaxku = buatajax();
 var url="kelas.php";
 url=url+"?kelas="+kls;
 ajaxku.onreadystatechange=state;
 ajaxku.open("GET",url,true);
 ajaxku.send(null);
}

function ambilguru(mpl){
 ajaxku = buatajax();
 var url="kelas.php";
 url=url+"?mapel="+mpl;
 ajaxku.onreadystatechange=stateGuru;
 ajaxku.open("GET",url,true);
 ajaxku.send(null);
}

function buatajax(){
 if (window.XMLHttpRequest){
 return new XMLHttpRequest();
 }
 if (window.ActiveXObject){
 return new ActiveXObject("Microsoft.XMLHTTP");
 }
 return null;
}
function state(){
var data;
 if (ajaxku.readyState==4){
 data=ajaxku.responseText;
 if(data.length>0){
 document.getElementById("mapel").innerHTML = data
 }else{
 document.getElementById("mapel").innerHTML = '';
 }
 }
}

function stateGuru(){
var data;
 if (ajaxku.readyState==4){
 data=ajaxku.responseText;
 if(data.length>0){
 document.getElementById("guru").innerHTML = data
 }else{
 document.getElementById("guru").innerHTML = '';
 }
 }

}

function tambah()
{
	ajaxku = buatajax();
	ajaxku.onreadystatechange=ambil;

}
function ambil()
 {
 	document.getElementById("form").innerHTML = '<input type="text"><button onclick=tambah()>click</button>';
 }
</script>
</head>
<body>
	<div id="form">
	<input type="text"><button onclick=tambah()>click</button> 
		
	</div>
</body>
</html>